﻿using System;

namespace WyUnity.Data.TableMapper
{
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class)]
    public class MapAttribute : Attribute
    {
        public MapAttribute() { }
        public MapAttribute(string field)
        {
            Name = field;
        }
        /// <summary>
        /// 字段名
        /// </summary>
        public string Name { get; protected set; }

        /// <summary>
        /// 标记是否延时加载
        /// </summary>
        public bool LazyLoad { get; set; }

        /// <summary>
        /// 标记是否为主键
        /// </summary>
        public bool IsKeyField { get; set; }

        /// <summary>
        /// 长度
        /// </summary>
        public int Length { get; set; }

        /// <summary>
        /// 新增记录时值是否由数据库自动生成
        /// 例如：自增类型、默认值
        /// </summary>
        public bool DBGenerate { get; set; }
    }
    /// <summary>
    /// 标记字段为行版本
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class RowVersionAttribute : MapAttribute
    {
        public RowVersionAttribute()
        {
            Name = "Modifier";
            Length = 8;
            DBGenerate = true;
        }
    }
}